<template>
	<!--新增对话框-->
	<el-dialog title="处理反馈" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
		<el-form :model="editForm" :rules="editFormRules" ref="editForm" label-width="100px" class="demo-editForm">
			<el-form-item label="备注" prop="remark" label-width="100px">
				<el-input v-model="editForm.remark" autocomplete="off"></el-input>
			</el-form-item>
			<el-form-item label="状态" prop="com_view" label-width="100px">
				<el-radio-group v-model="editForm.status">
					<el-radio label="HAS_HANDLED">已处理</el-radio>
					<el-radio label="WAIT_HANDLE">待处理</el-radio>
				</el-radio-group>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="submitForm('editForm')">处理</el-button>
				<el-button @click="resetForm('editForm')">重置</el-button>
			</el-form-item>
		</el-form>
	</el-dialog>
</template>

<script>
export default {
	name: 'FeedbackProcess',
	data() {
		return {
			editForm: {},
			editFormRules: {
				//status: [{ required: true, message: '请选择状态', trigger: 'blur' }],
			},
			dialogVisible: false,
		};
	},
	methods: {
		resetForm(formName) {
			this.$refs[formName].resetFields();
			this.dialogVisible = false;
			this.editForm = {};
		},
		handleClose() {
			this.resetForm('editForm');
		},
		submitForm(formName) {
			this.$refs[formName].validate((valid) => {
				if (valid) {
					console.log(this.editForm);
					const info = {
						com_save_request_list: [this.editForm],
						notice_text_id: this.notice_text_id,
					};
					this.$axios.post('/user/feedback/handle', this.editForm).then((res) => {
						this.$message({
							showClose: true,
							message: '恭喜你，操作成功',
							type: 'success',
							onClose: () => {
								this.$emit('refreshDataList');
							},
						});
						this.dialogVisible = false;
						this.resetForm(formName);
					});
				} else {
					console.log('error submit!!');
					return false;
				}
			});
		},
		init(item) {
			this.dialogVisible = true;
			const info = JSON.parse(JSON.stringify(item));
			this.editForm = {
				id: info.id,
				status: info.status,
				remark: info.remark,
			};
		},
	},
};
</script>

<style scoped></style>
